#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2025/6/16 16:58
# @Author  : Chenmm
# @File    : config.py
# @Software: PyCharm

import os

from starlette.config import Config

PROJECT_DIR_PATH = os.path.dirname(os.path.dirname(__file__))
config = Config(os.path.join(PROJECT_DIR_PATH, '.env'))

ENV = config.get("ENV", str, "DEV")

mysql_database = config.get("MYSQL_DB_DEV", str, "learn_onsite_system_dev")
if ENV == "TEST":
    mysql_database = config.get("MYSQL_DB_TEST", str, "learn_onsite_system_test")
elif ENV == "PRO":
    mysql_database = config.get("MYSQL_DB_PRO", str, "learn_onsite_system_pro")
else:
    pass

# mysql
MYSQL_CONFIG = {
    "host": config.get("MYSQL_HOST", str, "10.30.10.36"),
    "port": config.get("MYSQL_PORT", int, 3306),
    "username": config.get("MYSQL_USERNAME", str, "root"),
    "password": config.get("MYSQL_PASSWORD", str, "123456"),
    "database": mysql_database
}


# redis
REDIS_CONFIG = {
    "username": config.get("REDIS_USER_NAME", str, ""),
    "password": config.get("REDIS_PASSWORD", str, ""),
    "host": config.get("REDIS_HOST", str, "127.0.0.1"),
    "port": config.get("REDIS_PORT", str, "6378"),
    "db": config.get("REDIS_DB", int, 0)
}


# token
TOKEN_CONFIG = {
    "secret_key": config.get("SECRET_KEY", str, "08d25e094faa6ca2556c819756bhj9563b93f7099f6f0f4xxd6cf93b33e8d3e7"),
    "algorithm": config.get("ALGORITHM", str, "HS256"),
    "access_token_expire_time": config.get("ACCESS_TOKEN_EXPIRE_MINUTES", int, 30)
}